﻿using NB.MGJ.Common.MVC;
using NB.MGJ.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace NB.MGJ.Web.Controllers
{
    public class DataAnalyseController : BaseController
    {
        /// <summary>
        /// 第一版
        /// </summary>
        /// <returns></returns>
        public JsonResult GetAntiFakeDataAnalyseResult(int? sYear = null, int? eYear = null)
        {
            return Json(new
            {
                GlobalDataAnalyse = SystemDataAnalyse.GlobalDataAnalyse(),
                AntifakeYearAnalyse = SystemDataAnalyse.AntifakeAnalyseForPageOne(LogOnUser.ECode, sYear, eYear),
                SearchTopTen = SystemDataAnalyse.SearchTopTenForAntifake(LogOnUser.ECode),
                SearchTopTenPlace = SystemDataAnalyse.SearchPlaceTopTenForAntifake(LogOnUser.ECode)
            }, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 第二版
        /// </summary>
        /// <returns></returns>
        public JsonResult GetAntifleeingDataAnalyseResult(string sYear = null)
        {
            return Json(new
            {
                GlobalDataAnalyse = SystemDataAnalyse.GlobalDataAnalyse(),
                SearchTopTen = SystemDataAnalyse.SearchTopTenForAntifake(LogOnUser.ECode),
                OutTopSeven = SystemDataAnalyse.OutWarehouseTopSevenForEnterprise(LogOnUser.EnterpriseId.ToString()),
                InOrOutOrReturnAnalse = SystemDataAnalyse.AntifleeingAnalyseForPageTwo(LogOnUser.EnterpriseId.ToString(), sYear),
                AntifleeingTopTenForAntifake = new List<object>{
                  new {name="上海",value=70896},
                  new {name = "安徽",value=69900},
                  new {name="江苏",value=68009},
                  new {name="江西",value=40890},
                  new {name="浙江",value=40000},
                  new {name="山东",value=36542},
                  new {name="河南",value=15201},
                  new {name="四川",value=5230},
                  new {name="新疆",value=1250},
                  new {name="海南",value=8858}
                }
            }, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 第三版
        /// </summary>
        public JsonResult GetOriginsDataAnalyseResult(string sYear = null)
        {
            return Json(new
            {
                GlobalDataAnalyse = SystemDataAnalyse.GlobalDataAnalyse(),
                OriginsMaterial = SystemDataAnalyse.OriginsMaterialAnalyseForPageThree(LogOnUser.EnterpriseId.ToString(), sYear),
                SearchTopTen = SystemDataAnalyse.SearchTopTenForAntifake(LogOnUser.ECode),
                ScanCodeTopSevenForProduct = new List<object>
                {
                   new {Name="江永香柚",Value=7621},
                   new {Name="果秀",Value=6982},
                   new {Name="异蛇酒",Value=6641},
                   new {Name="金浩茶油",Value=5213},
                   new {Name="天龙米",Value=3478},
                   new {Name="香橙",Value=3478}
                },
                SearchTopTenPlace = new List<object>{
                    new {name="上海",value=70896},
                  new {name = "安徽",value=69900},
                  new {name="江苏",value=68009},
                  new {name="江西",value=40890},
                  new {name="浙江",value=40000},
                  new {name="山东",value=36542},
                  new {name="河南",value=15201},
                  new {name="四川",value=5230},
                  new {name="新疆",value=1250},
                  new {name="海南",value=4888}
                }
            }, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 第四版
        /// </summary>
        public JsonResult GetActivityDataAnalyseResult(string sYear = null, string sMonth = null)
        {
            return Json(new
            {
                AwardTopSeven = SystemDataAnalyse.AwardTopFiveForActivity(LogOnUser.ECode),
                ActivityAnalyse = SystemDataAnalyse.ActivityAnalyseForPageFour(LogOnUser.ECode, sYear, sMonth),
                ActivityProjectAnalyse = new List<object>
                {
                    new {
                      Name="红包",
                      Count=200,
                      Has = 184
                    },
                    new {
                      Name="九宫格",
                      Count=500,
                      Has = 250
                    },
                    new {
                      Name="刮刮卡",
                      Count=700,
                      Has = 690
                    },
                    new {
                      Name="砸金蛋",
                      Count=100,
                      Has = 85
                    },
                },
                PlaceTopTen = new List<object>{
                   new {name="上海",value=70896},
                  new {name = "安徽",value=69900},
                  new {name="江苏",value=68009},
                  new {name="江西",value=40890},
                  new {name="浙江",value=40000},
                  new {name="山东",value=36542},
                  new {name="河南",value=15201},
                  new {name="四川",value=5230},
                  new {name="新疆",value=1250},
                  new {name="海南",value=8808}
                }
            }, JsonRequestBehavior.AllowGet);
        }
    }
}